﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Text.RegularExpressions;

/// <summary>
/// Summary description for IDHandler
/// </summary>
public static class UrlRequestHandler
{
    static HttpRequest Request = HttpContext.Current.Request;
    static HttpServerUtility Server = HttpContext.Current.Server;
    //Httpser
    /// <summary>
    /// Gets the tab id.
    /// </summary>
    /// <returns></returns>
   public static int GetTabId()
    {
        
        object o = HttpContext.Current.Request.QueryString[ID.TabId];
        return GetInt(o);
    }
   /// <summary>
   /// Gets the infor id.
   /// </summary>
   /// <returns></returns>
   public static int GetInforId()
   {
      
       object o = HttpContext.Current.Request.QueryString[ID.InforId];
       return GetInt(o);
   }
   /// <summary>
   /// Gets the id.
   /// </summary>
   /// <returns></returns>
   public static int GetId()
   {
       
       object o = HttpContext.Current.Request.QueryString[ID.Id];
       return GetInt(o);
   }
   /// <summary>
   /// Gets the int.
   /// </summary>
   /// <param name="o">The o.</param>
   /// <returns></returns>
   private static int GetInt(object o)
    {
        int id = -1;
        if (o != null)
       {
           id = int.Parse(o.ToString());

       }
        return id;
    }

   //public static void RequestHandler()
   //{
       
   //    string strParentPageName = "";
   //    string strPageName = "";
   //    string strQ = "";
   //    int nIndex = 0;
   //    int nProductId = 0;
   //    string strSQL = "";

   //    strQ = Request.ServerVariables["SCRIPT_NAME"].ToString();

   //    // Decode the HTML
   //    // Strips Out Trash that the URL creators might
   //    // Have Entered
   //    strQ = Regex.Replace(strQ, "[_]", " ");
   //    strQ = Regex.Replace(strQ, "&nbsp;", " ");
   //    strQ = Regex.Replace(strQ, @"\+", " ");
   //    strQ = Regex.Replace(strQ, "%20", " ");
   //    strQ = Regex.Replace(strQ, "%C3%A9", "é");
   //    strQ = Regex.Replace(strQ, "%C3%A1", "á");
   //    strQ = Regex.Replace(strQ, "%27", "'");
   //    strQ = Regex.Replace(strQ, "%5C", "\\");

   //    // Strip Ending Slash If There Is One
   //    if (strQ[strQ.Length - 1] == '/')
   //    {
   //        strQ = strQ.Substring(0, strQ.Length - 1);
   //    }

   //    // Strip The Page Name
   //    nIndex = strQ.LastIndexOf("/");
   //    if (nIndex > 0)
   //    {
   //        strPageName = strQ.Substring(nIndex + 1, (strQ.Length - nIndex) - 1);
   //        strQ = strQ.Substring(0, nIndex);
   //    }

   //    // Transfer To the Home Page If There Appears
   //    // To Be a Problem With the URL, maybe a real 404?
   //    if (strPageName.Length < 4)
   //    {
   //        Server.Transfer("/Default.aspx");
   //    }

   //    // Trim Off .htm From Location Name
   //    if ((strPageName[strPageName.Length - 1] == 'm') &&
   //    (strPageName[strPageName.Length - 2] == 't') &&
   //    (strPageName[strPageName.Length - 3] == 'h') &&
   //    (strPageName[strPageName.Length - 4] == '.'))
   //    {
   //        strPageName = strPageName.Substring(0, strPageName.Length - 4);
   //    }

   //    // Now We Have The Name of the Page Decode Some More
   //    // Also Prep For A Database Call
   //    strPageName = Regex.Replace(strPageName, "'", "''");
   //    strPageName = Regex.Replace(strPageName, "%2F", "/");
   //    strPageName = Regex.Replace(strPageName, "%2f", "/");
   //    nProductId = 1231;
   //    //Server.Transfer("ChildPage.aspx?Product_Id=" + nProductId);
      

   //}


}
